import { ElMessageBox } from "element-plus";

//参数类型
interface ConfirmOptions {
  message: string;
  okfun?: () => void;
  showCancelBtn?: boolean;
  okText?: string;
}

const confirm = ({
  message,
  okfun,
  showCancelBtn = true,
  okText = "确定",
}: ConfirmOptions) => {
  ElMessageBox.confirm(message, "提示", {
    closeOnClickModal: false,
    confirmButtonText: okText,
    cancelButtonText: "取消",
    showCancelButton: showCancelBtn,
    type: "info",
  })
    .then(() => {
      okfun?.(); //可选链语法
    })
    .catch(() => {});
};

export default confirm;
